< previous page page_282 next page >

Page 282
z0302-01.gif
Figure 10.1
A tree covers more area than a simple line segment but
less than two-dimensional objects like rectangles.
numbers. By evaluating this simple equation many times, you can create a picture of amazing intricacy.
The sections that follow describe several different kinds of fractals. Some, like trees, are simple and regular. Others, such as the Mandelbrot set, seem almost alien in their twisted complexity.
Trees
You can define a tree recursively as a trunk attached to zero or more smaller trees. More intuitively, the trunk is attached to branches. The branches are attached to smaller branches that are attached to still smaller branches and so forth until you reach some point in the tree where there are no more branches. For example, you could write a program that continued drawing smaller and smaller branches until the new branches were less than one pixel long. At that point, the program would stop.
You can define the level or depth of a tree to be the number of branches between the bottom and the top of the tree. The tree in Figure 10.2, for instance, has five levels.
Drawing a tree like the one shown in Figure 10.2 is easy using a tree drawing subroutine that closely follows the recursive definition of a tree. This routine draws a branch of a given length in a given direction. It then calls itself recursively to draw smaller branches

 
< previous page page_282 next page >